package com.niiwoo.civet.trade.service.dubbo.loan;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import com.alibaba.dubbo.config.annotation.Service;
import com.niiwoo.civet.trade.dto.request.CreditAuditBackRequestDTO;
import com.niiwoo.civet.trade.dto.request.loan.ConfirmLoanRequestDTO;
import com.niiwoo.civet.trade.dto.response.loan.ConfirmResponseDTO;
import com.niiwoo.civet.trade.service.loan.SocialSecurityLoanDubboService;
import com.niiwoo.civet.trade.service.local.loan.LoanConfirmService;
import com.niiwoo.civet.trade.service.local.loan.creditaduit.SocailSecurityLoanCreditAduitService;

import lombok.extern.slf4j.Slf4j;

/**
 * @Description:社保贷统一dubbo服务接口类
 * @Author:zhoulinquan
 * @Date:2018/04/17
 */
@Slf4j
@Service(version = "1.0.0")
public class SocialSecurityLoanDubboServiceImpl implements SocialSecurityLoanDubboService {
    // 天秤授信反欺诈回调地址模型(AFP)
    public static final String TIANCHENG_AFP_CALLBACK_URL = "%s/tc/%s/%s/callback?functionCode=%s";
    public static final String LOAN_QUANTITY_LIMIT_KEY = "loan_quantity_limit";
    @Value(value = "${web-http-url}")
    private String webHttpUrl;

    static final int PRECISION_TWO = 2;

    @Autowired
    private LoanConfirmService loanConfirmService;
    
    @Autowired
    private SocailSecurityLoanCreditAduitService socailSecurityLoanCreditAduitService;

    /**
     * 社保贷借款费用计算
     * @param confirmLoanRequestDTO
     * @return
     */
    @Override
    public ConfirmResponseDTO calculateCost(ConfirmLoanRequestDTO confirmLoanRequestDTO){
        return loanConfirmService.loanConfirm(confirmLoanRequestDTO);
    }

    /**
     * 天秤信审回调
     */
	@Override
	public void tianchengCreditAuditCallback(CreditAuditBackRequestDTO creditAuditBackRequestDTO) {
		socailSecurityLoanCreditAduitService.creditAuditCallback(creditAuditBackRequestDTO);
	}

}
